from PyQt5.QtGui import QIcon, QPixmap, QColor
import os

def get_app_icon():
    """获取应用图标"""
    try:
        # 直接使用assets目录下的app.ico文件
        icon_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets/app.ico")
        return QIcon(icon_path)
    except Exception as e:
        print(f"获取应用图标时出错: {e}")
        # 创建一个基本图标作为后备
        pixmap = QPixmap(64, 64)
        pixmap.fill(QColor("#0078d4"))
        return QIcon(pixmap)

if __name__ == "__main__":
    # 测试获取图标
    icon = get_app_icon()
    print("应用图标已获取")
